<template>
  <Portlet title="认证详情">
    <el-form label-position="left" label-width="100px">
      <el-row>
        <el-col :span="24">
          <el-form-item label="公司姓名：">
            <span>{{detail.companyName}}</span>
          </el-form-item>
        </el-col>
        <el-col :span="24">
          <el-form-item label="公司地址：">
            <span>{{detail.address}}</span>
          </el-form-item>
        </el-col>
        <el-col :span="24">
          <el-form-item label="法人姓名：">
            <span>{{detail.name}}</span>
          </el-form-item>
        </el-col>
        <el-col :span="24">
          <el-form-item label="身份证号码：">
            <span>{{detail.idNum}}</span>
          </el-form-item>
        </el-col>
        <el-col :span="8">
          <el-form-item label="认证资料：">
            <UploadImage inline :value="getImage(detail.idFrontImg)" readonly></UploadImage>
          </el-form-item>
        </el-col>
        <el-col :span="8">
          <el-form-item>
            <UploadImage inline :value="getImage(detail.idBackImg)" readonly></UploadImage>
          </el-form-item>
        </el-col>
        <el-col :span="8">
          <el-form-item>
            <UploadImage inline :value="getImage(detail.companyImg)" readonly></UploadImage>
          </el-form-item>
        </el-col>
        <el-col :span="24">
          <el-form-item label="认证结果：">
            <span v-if="state == 2">认证失败</span>
            <span v-if="state == 0">审核中，请稍后......</span>
            <span v-if="state == 1">认证已通过</span>
          </el-form-item>
        </el-col>
        <el-col :span="24" v-if="state == 2">
          <el-form-item label="失败原因：">
            <span>{{detail.auditMemo}}</span>
          </el-form-item>
        </el-col>
        <el-col :span="6" :offset="8" v-if="state == 2">
          <el-form-item>
            <el-button class="btn green btn-block btn-lg" style="width:100%" type="primary" :loading="loading" @click.prevent="modify">重新提交</el-button>
          </el-form-item>
        </el-col>
      </el-row>
    </el-form>
  </Portlet>
</template>
<script>
import {dotData} from '@/utils'
export default {
  name: 'companyCertificationShow',
  data() {
    return {
      examineId: this.$route.params.id,
      state: this.$route.query.state,
      businessId: '',
      detail: {},
      loading: false
    }
  },
  created() {
    // 请求详情数据detail
    this.$ajax.get('/ms-fahuobao-user/OutGoodsUser/get-credential', {id: this.examineId}).then(response => {
      if (response.success) {
        this.detail = response.data
        this.businessId = dotData(response, 'data.businessId')
      }
    })
  },
  methods: {
    getImage(val) {
      if (Array.isArray(val)) {
        return val
      }
      if (val && typeof val === 'string') {
        return val.split(',')
      }
      return []
    },
    modify() {
      console.log('businessId555555555', this.businessId)
      this.$router.push({path: '/ss-fhb/companyCertification/edit/' + this.businessId + '/?examineId=' + this.examineId})
    }
  }
}
</script>
